#define _CRT_SECURE_NO_WARNINGS 1

class Solution {
public:
    vector<int> singleNumber(vector<int>& nums) {
        sort(nums.begin(), nums.end());
        vector<int> v1;

        vector<int>::iterator it = nums.begin();
        while (it != nums.end())
        {
            while (it + 1 == nums.end() || *it != *(it + 1))
            {
                v1.push_back(*it);
                if (v1.size() == 2)
                    break;
                if (it + 1 != nums.end())
                    it++;
            }
            if (v1.size() == 2)
                break;
            int temp = *it;
            while (*it == temp)
                it++;
        }
        return v1;
    }
};